﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Xml;

namespace BTCairo
{
    public class SVGType : SaveType
    {
        public SVGType(List<Shape> list, string _path, InfoGraphic _info)
        {
            this.listShape = list;
            this.path = _path;
            this.InfoGraphic = _info;
        }

        public override void Save()
        {
            path = path + @".svg";
            XmlTextWriter wr = new XmlTextWriter(path, Encoding.UTF8);
            wr.Formatting = Formatting.Indented;
            wr.WriteStartElement("svg");
            //wr.WriteStartAttribute(@"xmlns", @"");
            //wr.WriteEndAttribute();
            //wr.WriteStartAttribute(@"version", @"1.1");
            //wr.WriteEndAttribute();
            wr.WriteEndElement();
            wr.Close();

            XmlDocument doc = new XmlDocument();
            doc.Load(path);
            XmlElement root = doc.DocumentElement;

            root.SetAttribute(@"xmlns", @"http://www.w3.org/2000/svg");
            root.SetAttribute(@"version", @"1.1");

            //XmlElement circle = doc.CreateElement("circle");
            //circle.SetAttribute("cx", "100");
            //circle.SetAttribute("cy", "50");
            //circle.SetAttribute("r", "40");
            //circle.SetAttribute("stroke", "black");
            //circle.SetAttribute("stroke-width", "2");
            //circle.SetAttribute("fill", "red");
            //root.AppendChild(circle);

            foreach (Shape shape in listShape)
            {
                shape.ParseXmlElement(doc, root);
            }


            doc.Save(path);
        }
    }
}
